//
//  CGSChoolJobCell.m
//  SchoolClient
//
//  Created by mac on 15/11/3.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGSChoolJobCell.h"

@implementation CGSChoolJobCell

@synthesize titleLabel,schoolLabel,markLabel,timeLable;

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //招聘标题
        titleLabel = [[UILabel alloc]init];
        titleLabel.font = [UIFont systemFontOfSize:16];
        titleLabel.numberOfLines = 0;
        //titleLabel.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:titleLabel];
        
        //招聘学校
        schoolLabel = [[UILabel alloc]init];
        schoolLabel.font = [UIFont systemFontOfSize:15];
        schoolLabel.numberOfLines = 0;
        [self.contentView addSubview:schoolLabel];
        
        //招聘时间
        markLabel = [[UILabel alloc]init];
        //areaLabel.text = @"招聘时间:";
        markLabel.font = [UIFont systemFontOfSize:13];
        markLabel.textColor = [UIColor darkGrayColor];
        //markLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:markLabel];
        
       //招聘时间内容
        timeLable = [[UILabel alloc]init];
        //timeLable.text = @"Oct 17, 2015 5:27:32 PM";
        timeLable.font = [UIFont systemFontOfSize:13];
        timeLable.textColor = [UIColor darkGrayColor];
        //timeLable.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:timeLable];
        
    }
    return self;
}

-(void)setProductFrame:(CGInfoSchoolFrame *)productFrame{

    _productFrame = productFrame;
    
    titleLabel.text = productFrame.product.title;
    schoolLabel.text = productFrame.product.name;
    markLabel.text = @"招聘时间:";
    timeLable.text = [self getTimeWithDate:productFrame.product.recruitmentTimeStart];
    
    titleLabel.frame = productFrame.titleLabelF;
    schoolLabel.frame = productFrame.schoolLabelF;
    markLabel.frame = productFrame.timeTitleLabelF;
    timeLable.frame = productFrame.timeContentLabelF;
    
}

-(NSString *)getTimeWithDate:(NSString *)timeStr{
    
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc]init];
    NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
    [inputFormatter setLocale:locale];
    [inputFormatter setDateFormat:@"MMM dd, yyyy hh:mm:ss aa"];
    NSDate *inputDate = [inputFormatter dateFromString:timeStr];
    //创建日期模板对象,设置模板的显示格式
    NSDateFormatter *outputFormatter = [[NSDateFormatter alloc]init];
    outputFormatter.dateFormat = @"yyyy-MM-dd";
    //outputFormatter.dateFormat = @"yyyy-MM-dd";
    NSString *outputDate = [outputFormatter stringFromDate:inputDate];     //自动转换成当地时间
    return outputDate;
}

@end
